Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-hash

Package Overview
Dependencies
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-hash

Generate hashes from javascript objects in node and the browser.

  • 1.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17M
decreased by-13.67%
Maintainers
2
Weekly downloads
 
Created

What is object-hash?

The object-hash npm package provides a function to generate a hash from a JavaScript object using various algorithms. It is useful for creating unique identifiers for objects, comparing objects by their hash, and caching objects based on their content.

What are object-hash's main functionalities?

Generate hash from an object

This feature allows you to generate a hash string from a JavaScript object. The hash is determined by the object's content.

const hash = require('object-hash');
const myObject = { name: 'Alice', age: 25 };
const objectHash = hash(myObject);

Generate hash with different algorithms

This feature allows you to specify different hashing algorithms, such as 'md5', 'sha1', 'sha256', etc., to generate the hash.

const hash = require('object-hash');
const options = { algorithm: 'sha256' };
const objectHash = hash({ name: 'Alice', age: 25 }, options);

Exclude properties from hashing

This feature allows you to exclude the values of the properties from the hash, effectively hashing the structure (keys) of the object only.

const hash = require('object-hash');
const options = { excludeValues: true };
const objectHash = hash({ name: 'Alice', age: 25 }, options);

Respect object types

This feature allows you to ignore the type of the object when generating the hash, treating arrays and objects with the same content as equal.

const hash = require('object-hash');
const options = { respectType: false };
const objectHash = hash([1, 2, 3], options);

Other packages similar to object-hash

Keywords

FAQs

Package last updated on 12 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc